function save(){
    var num = document.getElementById("num").value;
    var fatherNum = document.getElementById("fatherNum").value;
    var name = document.getElementById("name").value;
    var url = document.getElementById("url").value;
    var arrange= document.getElementById("arrange").value;
    var notice= document.getElementById("notice").value;
    var system= document.getElementById("system").value;


    var table = document.getElementsByTagName("tbody")[0];
    var tr = table.insertRow(table.rows.length);
    tr.insertCell(0).innerHTML = num;
    tr.insertCell(1).innerHTML = fatherNum;
    tr.insertCell(2).innerHTML = name;
    tr.insertCell(3).innerHTML =url;
    tr.insertCell(4).innerHTML = arrange;
    tr.insertCell(5).innerHTML = notice;
    tr.insertCell(6).innerHTML = system;
    tr.insertCell(7).innerHTML = '<a onclick="modify(this)"><i class="fa fa-wrench"></i> 修改</a>';
    tr.insertCell(8).innerHTML = '<a onclick="remove(this)"><i class="fa fa-times"></i> 删除</a>';
    alert("新增成功");

    var num = document.getElementById("num");
    var fatherNum = document.getElementById("fatherNum");
    var name = document.getElementById("name");
    var url = document.getElementById("url");
    var arrange= document.getElementById("arrange");
    var notice= document.getElementById("notice");
    var system= document.getElementById("system");

    num.value = "";
    fatherNum.value="";
    name.value = "";
    url.value="";
    arrange.value="";
    notice.value="";
    system.value="";
}
function cancel(){
    var num = document.getElementById("num");
    var fatherNum = document.getElementById("fatherNum");
    var name = document.getElementById("name");
    var url = document.getElementById("url");
    var arrange= document.getElementById("arrange");
    var notice= document.getElementById("notice");
    var system= document.getElementById("system");
    num.value = "";
    fatherNum.value="";
    name.value = "";
    url.value="";
    arrange.value="";
    notice.value="";
    system.value="";
}
function modify(cell){
    tr = cell.parentNode.parentNode;//input --> td --> tr
    var text = tr.cells[2].innerText;
    //console.log(tr.cells[2].innerText);
    tr.cells[2].innerHTML = '<input id="comment' + tr.rowIndex + '" name="comment"' +
        'class="form-control" aria-required="true">';
    tr.cells[7].innerHTML = '<a onclick="confirm(this)"><i class="fa fa-wrench"></i> 确认</a>';
    var comment = document.getElementById("comment" + tr.rowIndex);
    comment.value = text;
}
function confirm(cell){
    tr = cell.parentNode.parentNode;//input --> td --> tr
    console.log(tr.cells[2].innerText);
    tr.cells[2].innerHTML = document.getElementById('comment' + tr.rowIndex).value;
    tr.cells[7].innerHTML = '<a onclick="modify(this)"><i class="fa fa-wrench"></i> 修改</a>';
}
function remove(cell){
    var tr=cell.parentNode.parentNode;//input --> td --> tr
    var table=document.getElementsByTagName("table")[0]
    table.deleteRow(tr.rowIndex);
}